<%@ page language="java" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!doctype html>
<html lang="en">
 <head>
   <%@ include file="/module/js.jsp"%>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
  *{ margin:0; padding:0; list-style:none;}
.tabs2{ margin:10px;}
.tabs2-nav:before, .tabs2-nav:after{ display:table; content:' ';}
.tabs2-nav:after{ width:100%; clear:both; border-bottom:1px solid #dddddd;}
.tabs2-nav li{ position:relative; float:left; margin-right:5px; border:1px solid #becbd2; border-bottom:none;}
.tabs2-nav li.active:after{ position:absolute; bottom:-1px; width:100%; display:block; content:' '; border-bottom:0px solid #fff;}
.tabs2-nav a{ display:block; padding:0 20px; line-height:30px; text-decoration:none; color:#000; font-size:14px;}
 
.tabs2-cnt{ padding:10px;}
.tabs2-content{ display:none;}
.tabs2-content:first-child{ display:block;}
  </style>
  <script>
 function openTab(){
	    var oTabs=document.getElementById('tabs1');
	    debugger;
	    var aTabsNav=oTabs.querySelectorAll('.tabs2-nav li');
	    var aTabsCnt=oTabs.querySelectorAll('.tabs2-content');
	   
	    for(var i=0;i<aTabsNav.length;i++){
	        aTabsNav[i].index=i;
	        if(aTabsNav[i].className=='active'){
	        	 aTabsNav[i].style.backgroundColor = '#cccccc';
	        }else{
	        	 aTabsNav[i].style.backgroundColor = '';
	        }
	        aTabsNav[i].onclick=function(){
	            for(var i=0;i<aTabsNav.length;i++){
	                aTabsNav[i].className='';
	                aTabsCnt[i].style.display='none';
	            }
	            
	            this.className='active';
	            aTabsCnt[this.index].style.display='block';
	        };
	    } 
	 
 } 
  window.onload=function(){
	  openTab();
};
  </script>
 </head>
 <body style="height: 100%">
  <div class="tabs2" id="tabs1">
        <ul class="tabs2-nav" style="background-color: #eeeeee;font-size: 13px;font-weight: bold;">
             <li class="active"><a href="javascript:openTab();">班主任设置范围</a></li>
             <li  ><a href="javascript:openTab();">材料项目信息</a></li>
        </ul>
        <div class="tabs2-cnt">
            <div class="tabs2-content" id="bzr_tab">
		      <form action="#" name="Form" id="Form" method="post">
				 <input type="hidden" name="idList" id="idList"/>
				<table cellpadding="1" cellspacing="1" border="0">
					<tr>
					<c:if test="${issued=='false'}">
					   <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"XGGL_BJXX_BJCL\")%>" key="add">	
						<td><input type="button" id="btnAdd" 	value="指 定 为 全 部 班 主 任"
							class="inputButton" style="margin:3px;"/></td>
						<td><input type="button"  onclick="javascript:addbzgr()" value="添 加 班 主 任"
							class="inputButton" style="margin: 3px;"/></td>
						</kl:permission>
						<kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"XGGL_BJXX_BJCL\")%>" key="delete">				 
						<td><input type="button" id="btnDelete"  value="删 除 班 主 任"
							 class="inputButton" style="margin: 3px;"/></td>
					     </kl:permission> 
				    </c:if>			  
					   <td><input type="button" id="returnBut1"  value="返 回" class="inputButton"/></td>		
					</tr>
				</table>
				   <br />
		      <table id="dg" class="easyui-datagrid "  style="width:100%;" 
				data-options="pagination:false,collapsible:true,method:'post',remoteSort:true">
				<thead>
					<tr>
						<th data-options="field:'parentid',width:50,align:'left',hidden: true"></th>
						<th data-options="field:'empid',width:50,align:'left',hidden: true"></th>
						<th data-options="field:'bjid',width:50,align:'left',hidden: true"></th>
					    <th data-options="field:'rangeid',checkbox:true,width:50,align:'left'"></th>
					    <th data-options="field:'rownumbers',width:50,align:'left',formatter:formxl">序号</th>
						<th data-options="field:'zgh',sortable:true,nowrap:true,width:150,align:'left'">工号</th>
						<th data-options="field:'xm',nowrap:true,width:180,align:'left',sortable:true">姓名</th>
						<th data-options="field:'xb',nowrap:true,width:120,align:'left',sortable:true">性别</th>
						<th data-options="field:'bjmc',nowrap:true,width:170,align:'left',sortable:true">班级名称</th>
						<th data-options="field:'xz',width:840,align:'left',sortable:true">材料</th>
					</tr>
				</thead>
			 </table>	
			</form>	
				
		   <div id="show" style="display: none;">
					<table cellpadding="0" cellspacing="0" border="0"class="table-border">
					 <tr>
				  	 <td style="clear:both; width: 45%">
				  	   <input class="text" name="searchemp" ondblclick="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"  onkeyup="javascript:filterSelectItems('sourseFromSelect2','fromSelect','fromSelect',this.value);"/><font color="green">在此查找</font> <br/>
				  	   <br/><label style="color:red;">未选择:</label><br/>
				  	   <select name="fromSelect" id="fromSelect" multiple="multiple" style="width:400px; height: 300px;">
							ondblclick="moveField('fromSelect','toSelect');">
										  <c:forEach items="${List}" var="data">
													     <%--   <option value="${data.emid}">${data.xm}</option> --%>
													      <option value="${data.bjid}">${data.xm}</option>
												          </c:forEach>
						</select>
						<select name="sourseFromSelect2" id="sourseFromSelect2" multiple="multiple" style="width: 220px; height: 150px; display: none;" >
						<option value="1">xxxx</option>
										  <c:forEach items="${List}" var="data">
													      <%-- <option value="${data.emid}">${data.xm}</option> --%>
													      <option value="${data.bjid}">${data.xm}</option>
												          </c:forEach>
				  	    </select>
				  	  </td>
				  	    <td align="center" style="width: 10%">
				  	    <input type="button"  onclick="moveAllField('fromSelect','toSelect');" style="width: 50px;" value=">>" /><br> <br/>
						<input type="button" onclick="moveField('fromSelect','toSelect');" style="width: 50px;" value=">" /><br/><br/>
						<input type="button"   style="width: 50px;" value="&lt" onclick="moveField('toSelect','fromSelect');"/><br/> <br/>
				     	<input type="button" style="width: 50px;" onclick="moveAllField('toSelect','fromSelect');"  value="&lt&lt" />
				     </td>
				     <td style="width: 45%"><br/><label style="color:red;">已经选中:</label><br/>
				     <select name="toSelect" id="toSelect" multiple="multiple"  class="text" selected="selected" style="width:400px;height: 300px;" ondblclick="moveField('toSelect','fromSelect');">
					 </select>
				    </td>	    
				  </tr>
				 </table>
	           </div>
            </div>
                      <div class="tabs2-content" id="cl_tab">
         <input type="hidden" name="id" id="id"  value="${data.xmid}"/>
         
		<table cellpadding="0" cellspacing="0" border="0" class="table-border" width="80%">
			<tr>
				<td  colspan="4">材料项目信息</td>
			</tr>
			<tr>
				<td class="table-header" colspan="4">材料项目信息</td>
			</tr>
			<tr>
				<td class="table-titleTD" style="width: 15%">材料项目名称:</td>
				<td class="table-contentTD" style="width: 35%">${data.xmmc}</td>
		    </tr>
		    <tr>
		   	    <td class="table-titleTD" style="width: 15%">排序次序:</td>
				<td class="table-contentTD">${data.orders}</td>
			</tr>
			
			<tr>
				<td class="table-titleTD" style="width: 15%">项目状态:</td>
				<td class="table-contentTD">
			     	<c:if test="${data.states=='true'}">有效</c:if>
					<c:if test="${data.states=='false'}">无效</c:if>
				</td>
			</tr>
		    <tr>
				<td class="table-titleTD" style="width: 15%">提交期限:</td>
				<td class="table-contentTD">${data.deadline1}</td>
			</tr>
			
		     <tr>
				<td class="table-titleTD" style="width: 15%">发布状态:</td>
				<td class="table-contentTD">
					<c:if test="${data.issued=='true'}">已发布</c:if>
					<c:if test="${data.issued=='false'}">未发布</c:if>
				</td>
		    </tr>
		    <tr>		
				
				<td class="table-titleTD" style="width: 15%">发布时间:</td>
				<td class="table-contentTD">${data.issuetime1}</td>
			</tr>
			
			<tr>
				<td class="table-titleTD">备注:</td>
				<td class="table-contentTD" colspan="2">${data.remark}</td>
			</tr>
		</table>
		<br/>
		</br>
		<table cellpadding="1" cellspacing="1" border="0" align="left">
			<tr>
				<%-- <c:if test="${data.issued=='true'}">
			    <td><input type="text" id="ButOK" class="inputButton" style="text-align: center;" value="选择班主任 " /></td>
			    </c:if> --%>
			    <c:if test="${data.issued=='false'}">
			       <c:if test="${_login_user_type==2}">
			       <kl:permission permisstionList="${permisstionList}" currentUser="${_login_console_user}" currentCatalogId="<%=CatalogUtils.getCatalogId(\"XGGL_BJXX_BJCL\")%>" key="modify">			
				  <td><input type="button" id="btnSave" class="inputButton" style="text-align: center;" value="修 改" /></td>
				  </kl:permission>
				</c:if>
				</c:if>
				<td><input type="button" id="returnBut"  class="inputButton" value="返 回"  style="text-align: center;"/></td>
			 </tr>
			
		</table>

            </div>  
          
          
        </div>        
    </div>
    
<script>
		
		    function formxl(value, row, index) {
	          return index;
	        } 
		
			$(document).ready(function() {
				 $("#btnSave").click(function() {
					 window.location.href ="${basePath}/bjxxClassMaterialProject/updateToview?id="+ $("#id").val();
		 		 });
				
			/* 	 $("#ButOK").click(function() {
					 window.location.href ="${basePath}/bjxxClassMaterialRange/index?xmid="+ $("#id").val();
		 		 }); */
				 
				 $("#returnBut").click(function() {
		 			 window.location.href='${basePath}/bjxxClassMaterialProject/index';
		 		 });
		 		 
				 $("#returnBut1").click(function() {
		 			 window.location.href='${basePath}/bjxxClassMaterialProject/index';
		 		 });
			});
		</script>
		
		
		
		<script type="text/javascript">
			$(document).ready(
							function() {
					         	$('#dg').datagrid({
					         		url:'${basePath}/bjxxClassMaterialRange/List?xmid='+${data.xmid},
									nowrap:false,
								 onSortColumn :function(sort,order){
								   var _sort=sort;
								   var _order=order;
								   var options=$('#dg').datagrid('getPager').data("pagination").options;
								   var page=options.pageNumber;
								   var pageSize=options.pageSize;
								   window.setTimeout(function(){
									   $.post("${basePath}/bjxxClassMaterialRange/List",{orderFlag:_order,orderField:_sort},
												function(data){
												  $('#dg').datagrid("loadData",data); 
											   });
											   },100);  
								   },
								   rowStyler: function(index,row){
								   }
								});
								
					         	$('#btnBreak').click(function() {
									   window.location.href = "${basePath}/bjxxClassMaterialProject/details?id="+$('#id').val();
								});
					         	
					         	
					         	$('#btnAdd').click(function() {
					         		     layer.confirm("您是否确定指定为全部班主任数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
					         			  $.ajax({
											    method : 'POST',
												url : '${basePath}/bjxxClassMaterialRange/add_bzr_all',
												data :{
													 xmid : $('#id').val()
												 },
											     traditional:true,//阻止深度序列化
											     dataType:"json",
												 success : function(result) {
													     if(result.statua=="100"){
													        layer.alert('添加班主任成功', {icon: 6});
													        location=location;
												         }else if(result.statua=="-99"){
												        	layer.alert('服务器异常', {icon: 5});
															return false;
													     }
												  }
										    }); 
					         		      
									  },function(index){
											layer.close(index);
									  });
								});
					         	
					         	
					         	
					         	$('#btnDelete').click(function() {
						               $("#idList").val("");
										var count = 0;
										var idList = new Array();
									    var sels = $("#dg").datagrid("getSelections");
								    	for(var i in sels){
								    		idList.push(sels[i].bjid);
								    		count++;
								    	}
										if (count == 0) {
											layer.alert("您至少选择一条删除记录信息", {icon: 3});
											return false;
										}else{
											  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
												    $("#idList").val(idList);
												    document.Form.action = "${basePath}/bjxxClassMaterialRange/delete?xmid="+$('#id').val();
													document.Form.submit();
											  },function(index){
													layer.close(index);
											  });
										}
									});

					         	
							});
			
		</script>
		
		<script>
$(document).ready(
					function() {
						
						$("#show").dialog({
							width : 'auto',
							height : 'auto',
							bgiframe : true,
							modal : true,
							draggable : true,
							resizable : false,
							title : '添加班主任',
							autoOpen : false,
						    buttons : {
						    '取消' : function() {
						    	$(this).dialog('close');
							},
							'确定' : function() {
								    var select = document.getElementById("toSelect");
								
								    var emidList=new Array();
								    for(i=0;i<select.length;i++){
								    	  emidList[i]=select[i].value;
								    }
									  if(emidList.length<1){
									     layer.alert("请选择一项", {icon: 3});
										 return false;
									  }
								  
								   $.ajax({
									    method : 'POST',
										url : '${basePath}/bjxxClassMaterialRange/add_bzr',
										data :{
											 emidList : emidList,
											 xmid : $('#id').val()
										 },
									     traditional:true,//阻止深度序列化
									     dataType:"json",
										 success : function(data) {
											     if(data.statua=="100"){
											        layer.alert('添加班主任成功', {icon: 6});
											        $(this).dialog('close');
											        location=location;
										         }else if(data.statua=="-99"){
										        	layer.alert('服务器异常', {icon: 5});
													return false;
											     }
										  }
								    }); 
								   
							}
						  }
						});

					});
	function addbzgr() {
		 $('#show').dialog('open');
	}
</script>		
 </body>
</html>